﻿<ResourceDictionary x:Class="Flux_Balance_Analysis.Styles"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
                    xmlns:local="clr-namespace:Flux_Balance_Analysis.Graphs"
	xmlns:Converters="clr-namespace:GraphSharp.Converters;assembly=GraphSharp.Controls"
	xmlns:WPFExtensions_AttachedBehaviours="clr-namespace:WPFExtensions.AttachedBehaviours;assembly=WPFExtensions">

    <Converters:EdgeRouteToPathConverter x:Key="routeToPathConverter" />

    <Style TargetType="{x:Type Controls:VertexControl}">
        <EventSetter Event="MouseDoubleClick" Handler="VertexControl_MouseDoubleClick" />
    </Style>
    
    <Style TargetType="{x:Type Controls:EdgeControl}">
        <EventSetter Event="MouseDoubleClick" Handler="EdgeControl_MouseDoubleClick" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:EdgeControl}">
                    <Canvas>
                        <Path Stroke="{TemplateBinding Foreground}"
                          StrokeThickness="2"
                          MinWidth="1"
                          MinHeight="1"
                          x:Name="edgePath">
                            <Path.Data>
                                <PathGeometry>
                                    <PathGeometry.Figures>
                                        <MultiBinding Converter="{StaticResource routeToPathConverter}">
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Source.(Controls:GraphCanvas.X)" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Source.(Controls:GraphCanvas.Y)" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Source.ActualWidth" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                Path="Source.ActualHeight" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Target.(Controls:GraphCanvas.X)" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Target.(Controls:GraphCanvas.Y)" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Target.ActualWidth" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="Target.ActualHeight" />
                                            <Binding RelativeSource="{RelativeSource TemplatedParent}"
                                                 Path="RoutePoints" />
                                        </MultiBinding>
                                    </PathGeometry.Figures>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <local:FBAEdgeControl FontSize="10" Foreground="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}" Content="{Binding Edge.Name, RelativeSource={RelativeSource TemplatedParent}}" />
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>